<div id="tabsContainer">
	<div data-options="title: '基本信息', iconCls: 'icon-standard-layout-header', refreshable: false, selected: true">
		<div class="form-container">
			<form id="form">
				<table class="tableform">
					<tr>
						<th style="width:70px;">上级公司：</th>
						<td colspan="4">
							<input id="pid" name="pid" class="easyui-validatebox" type="text" style="width: 282px; height:25px;" />
						 	<a onClick="$pid.combotree('setValue', '');" class="easyui-linkbutton ml-3" data-options="plain: true"><i class='fa fa-remove fa-120 pt-5 pb-4 icon-red'></i></a>
						 	<a onClick="$pid.combotree('reload')" class="easyui-linkbutton ml-3" data-options="plain: true"><i class='fa fa-refresh fa-120 pt-5 pb-4 icon-green'></i></a>
						</td>
					</tr>
					<tr>
						<th>公司名称：</th>
						<td style="position: relative;">
							<input name="fullName" class="easyui-validatebox" type="text" data-options="required: true" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">公司编码：</th>
						<td colspan="4">
							<input name="code" class="easyui-validatebox" type="text" data-options="required: true" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>公司简称：</th>
						<td style="position: relative;">
							<input name="shortName" class="easyui-validatebox" type="text" data-options="required: true" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">公司法人：</th>
						<td colspan="4">
							<input name="manager" class="easyui-validatebox" type="text" data-options="required: true" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>公司分类：</th>
						<td style="position: relative;">
							<input id="category" name="category" style="width:238px;height:25px;">
						</td>
						<th style="width:70px;">公司性质：</th>
						<td colspan="4">
							<input id="nature" name="nature" style="width:238px;height:25px;">
						</td>
					</tr>
					<tr>
						<th>负责人：</th>
						<td style="position: relative;">
							<input name="contact" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">联系电话：</th>
						<td colspan="4">
							<input name="phone" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>电子邮件：</th>
						<td style="position: relative;">
							<input name="email" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">传真：</th>
						<td colspan="4">
							<input name="fax" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>所在省：</th>
						<td style="position: relative;">
							<input name="province" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">所在市：</th>
						<td colspan="4">
							<input name="city" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>所在县区：</th>
						<td style="position: relative;">
							<input name="county" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">邮编编码：</th>
						<td colspan="4">
							<input name="postalcode" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>详细地址：</th>
						<td colspan="4">
							<input name="address" class="easyui-validatebox" type="text" style="width:96.4%;" />
						</td>
					</tr>
					<tr>
						<th>公司网址：</th>
						<td style="position: relative;">
							<input name="web" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">开户信息：</th>
						<td colspan="4">
							<input name="accountInfo" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>公司描述：</th>
						<td colspan="4">
							<textarea name="description" style="width:96.8%;height:100px;"></textarea>
						</td>
					</tr>
					<tr>
						<th>备注：</th>
						<td colspan="4">
							<textarea name="remark" style="width:96.8%;height:100px;"></textarea>
						</td>
					</tr>
					<tr>
						<th>选项：</th>
						<td colspan="4" style="position: relative;">
							<div id="icheck" class="defaultSelect" style="position: absolute;left:5px;top:5px;">
								<input id="input-2" type="checkbox" name="defaultSelect"> <label class="irl" for="input-2">默认选中</label>
							</div>
						</td>
					</tr>
					<tr style="display:none">
						<td>
							<input type="hidden" name="id" value="${id!}">
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<div data-options="title: '自定义属性', iconCls: 'icon-standard-layout-header', refreshable: false">
		<div class="form-container">
			<form id="form">
				<table class="tableform">
					<tr>
						<th>注册资本：</th>
						<td style="position: relative;">
							<input name="aa" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">实收资本：</th>
						<td colspan="4">
							<input name="bb" class="easyui-validatebox" type="text" data-options="" style="width:230px;"/>
						</td>
					</tr>
					<tr>
						<th>经营范围：</th>
						<td style="position: relative;">
							<input name="cc" class="easyui-validatebox" type="text" data-options="" style="float:left;width:230px;"/>
						</td>
						<th style="width:70px;">成立日期：</th>
						<td colspan="4">
							<input name="dd" class="Wdate" style="width:236px;" type="text" onFocus="WdatePicker({isShowClear:true,readOnly:true})"/>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</div>

<script>
	var form_url = "${ctx}/manager/base/company/add", id = "${id!}";
	$(function(){
		$("#tabsContainer").tabs({
			fit: true, border: false
		}) ;
		$('#icheck input').iCheck({
			checkboxClass: 'icheckbox_minimal-blue',
			radioClass: 'iradio_square-blue'
	   	});
	   	
	   	$("#category").combobox({
			textField: 'value', valueField: 'label',
			data: [{ label: '集团', value: '集团' },{ label: '公司', value: '公司' },{ label: '分公司', value: '分公司' },{ label: '子公司', value: '子公司' }],
			panelHeight:'auto', editable:false, autoShowPanel: true
		}) ;
	   	$("#nature").combobox({
			textField: 'value', valueField: 'label',
			data: [{ label: '国家机关', value: '国家机关' },{ label: '建筑业', value: '建筑业' },{ label: '社会服务业', value: '社会服务业' }],
			panelHeight:'auto', editable:false, autoShowPanel: true
		}) ;
		
		
		
		$("#pid").combotree({
			url: "${ctx}/manager/base/company/treegrid",  method: "GET",
			idFiled:'pid', editable: false, required:false, lines:true, autoShowPanel: false
		});
		console.info(id);
		if(undefined != id && "" != id) {
			form_url = "${ctx}/manager/base/company/update" ;
			$.ajax({
				type: "GET", dataType: "JSON",
				url: "${ctx}/manager/base/company/get/"+id,
				success: function(result) {
					$("#form").form("load", result);
				},
				complete: function(XMLHttpRequest, textStatus){},
				error: function(XMLHttpRequest, textStatus, errorThrown){
					$.easyui.loaded();
					if(XMLHttpRequest.status == 403) {
						$.messager.alert(XMLHttpRequest.statusText, XMLHttpRequest.responseText, "warning");
					} else {
						$.messager.alert("错误", "发生未知错误", "error");
					}
				}
			});
		}
		
		
	});
	
	//提交表单数据
	var submitNow = function($d, $tg, flag) {
		var data = $("#form").form("getData");

		$.post(form_url, data, function(result) {
			if (result.status) {
				$tg.treegrid('reload');alertify.success(result.message);$.easyui.loaded();
				if(flag==undefined||flag==false){$d.dialog("close") ;}
			} else {
				$.easyui.loaded();$.messager.alert("错误", result.message, "error");
			}
		}, 'json').error(function() { $.easyui.loaded(); });
	};
	
	//验证表单
	var submitForm = function($d, $tg, flag) { 
		if($('#form').form('validate')) {
			$.easyui.loading({ msg: "数据提交中，请稍等..." });
			submitNow($d, $tg, flag) ;
		}
	};
</script>

